// Copyright (C) joyinter
// All rights reserved.
// 
// Author : Jiang Li
// Date   : 2005-5-12

#ifndef __CHECKBASE_H_COMMON_GUARD__
#define __CHECKBASE_H_COMMON_GUARD__

#pragma once


namespace JoyGuard
{

//##ModelId=44C4B60E01D4
class CheckBase
{
public:
	//##ModelId=44C4B60E0214
    enum ErrorCode
    {
		//##ModelId=44C4B60E0216
        EC_OK,
		//##ModelId=44C4B60E0217
        EC_FAILED,
		//##ModelId=44C4B60E0222
        EC_READ_MEMORY,
		//##ModelId=44C4B60E0223
        EC_CHECK_IMAGE,
		//##ModelId=44C4B60E0224
        EC_CHECK_FILE,
		//##ModelId=44C4B60E0225
        EC_NO_MODULE,
    };
	//##ModelId=44C4B60E0232
    class ECheckStop : public std::exception
    {
    };

	//##ModelId=44C4B60E01D5
    HANDLE  m_checkThread;
	//##ModelId=44C4B60E01D6
    DWORD   m_error;
	//##ModelId=44C4B60E01E4
    HANDLE  m_waitEvent;
	//##ModelId=44C4B60E01E5
    DWORD   m_readSize;
	//##ModelId=44C4B60E01E6
    DWORD   m_readDelay;
	//##ModelId=44C4B60E01E7
    DWORD   m_readed;
	//##ModelId=44C4B60E01F4
    DWORD   m_checkDelay;
	//##ModelId=44C4B60E01F5
    bool    m_stopped;

	//##ModelId=44C4B60E01F6
    void CheckStop();
	//##ModelId=44C4B60E01F7
    void ReadMemory(HANDLE hProcess, BYTE* dst, BYTE* src, int len);

	//##ModelId=44C4B60E0205
    virtual void CheckProc();
public:

	//##ModelId=44C4B60E0207
    CheckBase();
	//##ModelId=44C4B60E0208
    ~CheckBase();

	//##ModelId=44C4B60E0209
    virtual bool Create();
	//##ModelId=44C4B60E020B
    virtual void Close();
};


} // namespace JoyGuard

#endif  // __CHECKBASE_H_COMMON_GUARD__
